import java.util.Scanner;

public class 阶乘 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入整数n: ");
        int n = scanner.nextInt();
        System.out.println(sum(n));
    }
    public static int sum(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int p = 1;
            for (int j = 1; j <= i; j++) {
                p *= j;
            }
            sum +=  p;
        }
        return sum;
    }
}
